﻿using Neo4jClient;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WinFormsApp1
{
    internal class Neo4JServe
    {
        private BoltGraphClient m_client;

        public BoltGraphClient Client { get => m_client; set => m_client = value; }


        internal void Initialize()
        {
            BuildClient("172.18.8.94", "7687", "neo4j", "agcimneo4j");
        }

        private BoltGraphClient BuildClient(string ip,string port,string userName,string password)
        {
            // 初始化 Neo4j 客户端
            var client = new BoltGraphClient(new Uri($"bolt://{ip}:{port}"), userName, password);
            client.ConnectAsync().Wait();

            Client = client;
            return client;
        }

        internal void Dispose()
        {
            if(m_client!= null)
            {
                m_client.Dispose();
                m_client = null;
            }
        }
    }
}
